#ifndef SNAKEGAME_H
#define SNAKEGAME_H

#include <QObject>
#include <QMap>
#include <QList>

#include "defines.h"
#include "snakefield.h"
#include "snakesnake.h"
#include "snakebonus.h"

class SnakeGame : public QObject
{
    Q_OBJECT
private:
    SnakeField *field;
    QMap<quint32, SnakeSnake*> snakes;
    QMap<quint32, char> privDir;
    QMap<quint32, SnakeBonus *> bonuses;


    void moveSnake(quint32 ID, char direction);

    QList<QPair<quint32, quint32> > detectCollision();
    void processCollision(QList<QPair<quint32, quint32> > collisions, QMap<quint32, QString> &answer);

    void respawnSnake(quint32 ID);
    void killSnake(quint32 ID);


    void createBonus(quint32 bonusID);

    //TODO: algorithm to find free space for snake(in future for bonus)
public:
    explicit SnakeGame(QObject *parent = 0);

    //TODO: start game with parametrs(field size, map, etc.)

    void addSnake(quint32 ID);
    void deleteSnake(quint32 ID);


    QString updateSituation(const QString &events);

    QString getField();
    QString getSnakeBody(quint32 ID);
    QString getBonus(quint32 ID);


    quint32 getPointsOfSnake(quint32 ID);

    QString getBonuses();
signals:
    
public slots:
    
};

#endif // SNAKEGAME_H
